package com.vrv.app.cyberspace.modules.sys.entity;

import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * <p>
 * </p>
 *
 * @author sm
 * @since 2017-12-15
 */
@TableName("DAILY_REPORT")
public class DailyReport extends Model<DailyReport> implements Cloneable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
     * 标题
     */
    private String title;
    /**
     * 发布单位
     */
    private String releaseUnit;
    /**
     * 发布人
     */
    private String releaseMan;
    /**
     * 报告周期开始时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date cycleStartTime;
    /**
     * 报告周期结束时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date cycleEndTime;
    /**
     * 每天发布时间(定时器CRON)
     */
    private String dailyReleaseTime;
    /**
     * 每天反馈截止时间
     */
    private String dailyEndedTime;
    /**
     * 报告要求
     */
    private String requirement;
    /**
     * 发布单位IDs集合
     */
    private String unitIDsSet;
    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 是否已经发布
     */
    private Integer isRelease;


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getReleaseUnit() {
        return releaseUnit;
    }

    public void setReleaseUnit(String releaseUnit) {
        this.releaseUnit = releaseUnit;
    }

    public String getReleaseMan() {
        return releaseMan;
    }

    public void setReleaseMan(String releaseMan) {
        this.releaseMan = releaseMan;
    }

    public Date getCycleStartTime() {
        return cycleStartTime;
    }

    public void setCycleStartTime(Date cycleStartTime) {
        this.cycleStartTime = cycleStartTime;
    }

    public Date getCycleEndTime() {
        return cycleEndTime;
    }

    public void setCycleEndTime(Date cycleEndTime) {
        this.cycleEndTime = cycleEndTime;
    }

    public String getDailyReleaseTime() {
        return dailyReleaseTime;
    }

    public void setDailyReleaseTime(String dailyReleaseTime) {
        this.dailyReleaseTime = dailyReleaseTime;
    }

    public String getDailyEndedTime() {
        return dailyEndedTime;
    }

    public void setDailyEndedTime(String dailyEndedTime) {
        this.dailyEndedTime = dailyEndedTime;
    }

    public String getRequirement() {
        return requirement;
    }

    public void setRequirement(String requirement) {
        this.requirement = requirement;
    }

    public String getUnitIDsSet() {
        return unitIDsSet;
    }

    public void setUnitIDsSet(String unitIDsSet) {
        this.unitIDsSet = unitIDsSet;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Integer getIsRelease() {
        return isRelease;
    }

    public void setIsRelease(Integer isRelease) {
        this.isRelease = isRelease;
    }

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

    @Override
    public String toString() {
        return "DailyReport{" +
                ", id=" + id +
                ", title=" + title +
                ", releaseUnit=" + releaseUnit +
                ", releaseMan=" + releaseMan +
                ", cycleStartTime=" + cycleStartTime +
                ", cycleEndTime=" + cycleEndTime +
                ", dailyReleaseTime=" + dailyReleaseTime +
                ", dailyEndedTime=" + dailyEndedTime +
                ", requirement=" + requirement +
                ", unitIDsSet=" + unitIDsSet +
                ", createTime=" + createTime +
                "}";
    }

    @TableField(exist = false)//排除非表中字段
    private String selections;

    public String getSelections() {
        return selections;
    }

    public void setSelections(String selections) {
        this.selections = selections;
    }

    @TableField(exist = false)
    private Integer fId;

    public Integer getfId() {
        return fId;
    }

    public void setfId(Integer fId) {
        this.fId = fId;
    }

    @TableField(exist = false)
    private Integer flag;

    @TableField(exist = false)
    private String startTime;
    @TableField(exist = false)
    private String endTime;
    @TableField(exist = false)
    private String linkdoodID;

    @TableField(exist = false)
    private Integer page;
    @TableField(exist = false)
    private Integer size;

    /**
     * 已反馈
     */
    @TableField(exist = false)
    private int hadFeedback;

    @TableField(exist = false)
    private List<OrganizeTable> orgList;

    public Integer getFlag() {
        return flag;
    }

    public void setFlag(Integer flag) {
        this.flag = flag;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public String getLinkdoodID() {
        return linkdoodID;
    }

    public void setLinkdoodID(String linkdoodID) {
        this.linkdoodID = linkdoodID;
    }

    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Integer getSize() {
        return size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    public Integer getHadFeedback() {
        return hadFeedback;
    }

    public void setHadFeedback(Integer hadFeedback) {
        this.hadFeedback = hadFeedback;
    }

    public Integer getTotalFeedback() {
        JSONArray jsonArray = JSONArray.parseArray(unitIDsSet);
        return jsonArray != null ? jsonArray.size() : 0;
    }

    public Integer getHavingFeedback() {
        return getTotalFeedback() - hadFeedback;
    }

    public List<OrganizeTable> getOrgList() {
        return orgList;
    }

    public void setOrgList(List<OrganizeTable> orgList) {
        this.orgList = orgList;
    }

    @Override
    public DailyReport clone() {
        try {
            return (DailyReport) super.clone();
        } catch (CloneNotSupportedException e) {
            return new DailyReport();
        }
    }
}
